package com.zxx.order.service.impl

import com.zqq.baselibrary.ext.convert
import com.zqq.baselibrary.ext.convertBoolean
import com.zxx.order.service.ShipAddressService
import com.zxx.order.service.bean.ShipAddress
import com.zxx.order.service.repository.ShipAddressRepository
import rx.Observable
import javax.inject.Inject

/**
 * 收货人信息 业务实现类
 * wc
 * @author zqq on 2019/6/30.
 */
class ShipAddressServiceImpl @Inject constructor() : ShipAddressService {

    @Inject
    lateinit var repository: ShipAddressRepository

    //添加收货人信息
    override fun addShipAddress(shipUserName: String, shipUserMobile: String, shipAddress: String): Observable<Boolean> {
        return repository.addShipAddress(shipUserName, shipUserMobile, shipAddress)
                .convertBoolean()
    }

    //获取收货人信息列表
    override fun getShipAddressList(): Observable<MutableList<ShipAddress>?> {
        return repository.getShipAddressList()
                .convert()
    }

    //修改收货人信息
    override fun editShipAddress(address: ShipAddress): Observable<Boolean> {
        return repository.editShipAddress(address)
                .convertBoolean()
    }

    //删除收货人信息
    override fun deleteShipAddress(id: Int): Observable<Boolean> {
        return repository.deleteShipAddress(id)
                .convertBoolean()
    }

}